package com.pengtu.gsj.taglib;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.lang.StringUtils;




public class TextTag extends BodyTagSupport{
    /**
	 * serialVersionUID:
	 *
	 * @since 1.0.0
	 */
	
	private static final long serialVersionUID = 1L;

	private int limit = 0;
	
	private int row = 0;
	
	public int doEndTag()throws JspException{
		try{
			if(bodyContent!=null){
				String str = bodyContent.getString();
				String result = "";
				if(StringUtils.isEmpty(str)|| limit == 0){
					return EVAL_PAGE;
				}
				if(limit != 0){
					if(str.length()> limit){
						result = "<span title='" + str + "'>"+str.substring(0, limit)+"<SUB>...</SUB></span>";
					} else {
						result = str;
					}
				}
				pageContext.getOut().write(result);
			}
		}catch(java.io.IOException ex){
			throw new JspTagException("IOError:"+ex.getMessage());
		}
		return EVAL_PAGE;
	}
	
	
	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
}